#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QTreeWidget>
#include <QMenu>
#include <QAction>
#include <QPoint>
#include <QTimer>
#include <QLabel>
#include <QPropertyAnimation>
#include <QTabWidget>
#include <QTabBar>
#include <QMap>
#include "smtpmailer.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public slots:
    void on_login_button_clicked();
    void on_exit_button_clicked();
    void on_exit_button1_clicked();
    void showContextMenu(const QPoint &pos);
    void sendEmailForAlarm();
    void showTabContextMenu(const QPoint &pos);
    void openTabInNewWindow();

private slots:
    void flashColorBlock();

private:
    Ui::MainWindow *ui;
    QMenu *contextMenu;
    QAction *sendEmailAction;
    
    // Tab右键菜单相关
    QMenu *tabContextMenu;
    QAction *openInNewWindowAction;
    int rightClickedTabIndex;
    
    // 颜色块闪烁相关
    QTimer *flashTimer;
    QVector<QLabel*> colorBlocks;
    QLabel *currentFlashingLabel;
    QPropertyAnimation *flashAnimation;
    QString originalStyleSheet;
    bool isFlashing;  // 添加缺失的成员变量
    QMap<QString, QString> originalColors; // 存储各个标签的原始颜色

    void setRowBackground(int row, const QColor &color);/*设置表格行背景颜色*/
    void clearAllBackgrounds();/*清楚表格所有行的背景色*/
    void initActiveTable();
    void initVoiceTable();
    void initAcknowledgedTable();
    void addMultipleNodes();
    void initWidget();
    void initColorBlockFlashing();
};
#endif // MAINWINDOW_H
